package com.wxx.design.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jetwang
 * @version 1.0
 * @date 2022/4/20 20:34
 */
public class EmployeeFactory {
    /**
     * 容器单例
     */
    private static final Map<String, Employee> EMPLOYEE_MAP = new HashMap<>();

    public static Employee getManager(String department) {
        Manager manager = (Manager) EMPLOYEE_MAP.get(department);
        if (manager == null) {
            manager = new Manager(department);
            manager.setReportContent(department + "部门汇报:此次汇报内容是...");
            EMPLOYEE_MAP.put(department, manager);
            System.out.println("创建部门经理:" + department);
        }
        return manager;
    }
}
